Skip to content

Release candidate 4.6.2 - #302

Merged
jwrosewell merged 33 commits into
mainfrom
rc
Dec 1, 2026
Merged

jwrosewell merged 33 commits into
mainfrom
rc

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Status, 1 December: rc is at 8a005b1b.

This pull request releases rc into main as 4.6.2. It completes the 4.6.2 release that #240 began. #240 merged at 07:15 UTC on 1 December 2026, and Publish was stopped before it uploaded anything, so no package is on PyPI at 4.6.2 and no 4.6.2 tag exists. Publish works the version out when this merges, and nothing in the repository sets it. Every package this repository publishes moves to 4.6.2, as #240 describes, and the changes below come on top of #240's.

The cloud available properties test may fail in this pull request's checks, because the CI resource key doesn't yet include the new ServiceWorkers property (tests/test_properties.py::PropertyTests::test_available_properties, "Property: serviceworkers is not present in the results").

Behaviour changes since #240

  1. The response cache of the Cloud Request Engine never stores or serves a response made for one visitor (Send every page iteration to the cloud, and keep responses made for one visitor out of the cache #295). That covers:
    • a request carrying a session id, a sequence, a JA4 or HTTP/2 settings, under any prefix and in any letter case,
    • a response carrying the browser tests' script,
    • a response carrying a sealed HumanConfidence result, being text that is not blank and is none of High, Medium and Low in any letter case, whatever HumanConfidenceSource says, and
    • a response carrying a 51Did.
  2. With the JavaScript builder on, which is the builders' default, the cache answers no request (Key the cloud engines' cache on the request's evidence and apply the Cloud Request Engine's cache rules #300). The sequence element gives every request a session id and a sequence, so every request goes to the cloud service. The cache answers repeated requests only in a pipeline built with add_javascript_builder=False. Expect more requests to the cloud where a pipeline relied on the cache.
  3. 51D_ values are part of the cache key (Cache key 51D_ values, per-visitor cache tests, thread-safe LRU cache and a warning for a cloud engine cache #301). The Cloud Request Engine accepts every query and cookie value whose name starts with 51D_, in any letter case and including the name 51D_ alone, beside the evidence keys the service lists, so two requests that differ only in such a value never share a cached response. The values are also part of the ETag of the web integration's client side responses. The Vary header is unchanged.
  4. The cloud pipeline builders put their cache on the Cloud Request Engine (Key the cloud engines' cache on the request's evidence and apply the Cloud Request Engine's cache rules #300). This covers the cache setting of DeviceDetectionCloudPipelineBuilder, IpIntelligenceCloudPipelineBuilder, LocationPipelineBuilder, and the cloud branch of DeviceDetectionPipelineBuilder and IpIntelligencePipelineBuilder. A cloud engine keeps no cache of its own, so each request gets the values from its own response.
  5. set_cache on a cloud engine is ignored with a warning (Cache key 51D_ values, per-visitor cache tests, thread-safe LRU cache and a warning for a cloud engine cache #301). Code that gives a cloud engine, DerivedCloud included, a cache keeps starting. The engine keeps no cache and logs one warning that names it and says to add the cache to the Cloud Request Engine.
  6. HumanConfidence is only High, Medium or Low (Read only High, Medium and Low as HumanConfidence values #297). A cloud response whose HumanConfidence is Unknown, or any other text, gives the property no value, with the missing property reason, so reading .value() raises as for any missing property.
  7. LRUEngineCache is safe to share between threads (Cache key 51D_ values, per-visitor cache tests, thread-safe LRU cache and a warning for a cloud engine cache #301). Each read and write holds a lock. A subclass whose constructor sets its cache without calling the constructor of LRUEngineCache keeps working, with the lock made on first use (Let a subclass of LRUEngineCache that skips its constructor read and write #303).

CI and tests

Branches not on rc

Every branch with commits not on rc was checked at rc 802efb1, before #301 merged:

When the last release merged

#240, 4.6.2, merged at 07:15 UTC on 1 December 2026 and published nothing. Before it, #114 merged at 06:22 UTC on 13 November 2026.

Pull requests in this release

The pull requests merged into rc since #240, in the order they merged:

Jamesr51d and others added 30 commits November 26, 2026 12:50
…est answers and visitor connection to the cloud
Nothing in CI ran the examples against the packages customers install
from PyPI, so a release whose packages do not work together, or that
leaves out something the examples need, was only found by a customer.

The new workflow, Examples vs Published Packages, installs every package
ci/packages.json marks for publishing from PyPI, each pinned to the
version given when the workflow is run by hand or otherwise to its latest
version, and takes only the three examples packages and their tests from
this checkout. It checks that each published package was installed from
PyPI at the pinned version, then runs the tests of the Device Detection,
IP Intelligence and Pipeline examples on the free data files, with the
resource key and licence keys the cloud tests read. A missing key, a
missing data file or a skipped test fails the run, because a run that
skips has checked nothing. The tests marked staging are left out, as only
the Cloud Human Confidence workflow is given the staging cloud.

It runs by hand, after each run of Publish or Nightly Pipeline that was
not cancelled, and on a pull request that changes the workflow.

Checked with ci/check-environment-variable-names.ps1 and the Pester tests
in ci/key-names.Tests.ps1, ci/check-environment-variable-names.Tests.ps1
and ci/free-threaded-python.Tests.ps1, 246 passed and none failed.
Two files conflicted, each where rc and this branch changed the same
lines.

In cloudrequestengine.py, CloudRequestEngine.process, rc skips the cache
for a request that carries a sealed Human Confidence result, because a
sealed result redeems once. This branch skips the cache for a request
that bypasses_cache picks out, being one carrying a session id, a
sequence, a JA4 or an H2, because the cache key leaves those out. The
resolution skips the cache when either is true. As on rc, the call to
process_internal is not assigned, because process_internal returns
nothing and pylint flags the assignment.

In constants.py, rc added HIDDEN_VALUE and this branch added
UNCACHED_EVIDENCE_NAMES in the same place. Both are kept.

The cloud request engine's tests pass with no keys set (185 passed, 2
skipped live licence key tests, 4 live tests deselected). Taking out
either condition fails a test, being
test_a_request_with_a_sealed_result_skips_the_cache for the sealed
result, and test_every_iteration_reaches_the_cloud_through_a_cache and
test_a_supplied_connection_is_never_served_from_a_cache for
bypasses_cache.
The first run against the packages on PyPI
(https://github.com/51Degrees/51degrees-python/actions/runs/46601762739,
attempt 3) showed two gaps in the job.

The Device Detection tests of the data file update example serve a copy
of TAC-HashV41.hash, and failed with "TAC-HashV41.hash is missing". The
job now fetches it with common-ci's fetch-assets action and the data
license from LICENSE_KEY_V4TAC_IPIV4ENTERPRISE, without keeping it in the
Actions cache because it is licensed, and puts it in
cxx/data/device-detection.

A test module that could not be imported stopped pytest before any test
of that package ran, so the IP Intelligence and Pipeline examples gave
no totals. pytest now runs with --continue-on-collection-errors, which
still fails the job on each module that cannot be imported.

Checked with ci/check-environment-variable-names.ps1 and the Pester tests
in ci/key-names.Tests.ps1, ci/check-environment-variable-names.Tests.ps1
and ci/free-threaded-python.Tests.ps1, 246 passed and none failed.
Each call to Node in test_javascriptbuilder_object_name.py had a 60 second
limit, and the first call on a runner also paid for Node's first start,
which took up to 17.8 seconds on the Windows runners measured and once
more than 60 seconds. The module now starts Node once before the tests,
with a limit of 300 seconds for that start, so each check and run of the
script keeps the 60 second limit for its own work. Both limits are named
constants. What the tests check is unchanged.
A cloud response made for one visitor is never stored in or served from
the response cache. The branch already kept out a response holding a
51Did (a top-level fodid) and a request carrying a session id, a
sequence, a JA4 or an H2, and rc kept out a request carrying a sealed
result to redeem. is_cacheable now also keeps out:

- a response carrying a sealed Human Confidence result, being a
  derived.humanconfidence whose value is text that is not blank and is
  none of High, Medium or Low. HumanConfidenceSource is never read,
  because the route decides sealing and a sealed result can be Passive
  or Active.
- a response carrying the browser tests' script, being a
  browserderived.browsertestsjavascript that is not blank.

Member names are compared in any case, as fodid already was.

The comments on bypasses_cache and UNCACHED_EVIDENCE_NAMES now give the
reason the rule gives, a request made for one visitor, and no longer say
the cloud service does not list the JA4 and H2, which its evidence key
list now does.

New tests in test_cloudrequestengine_cache.py cover a sealed Passive
result, a sealed result with any source, an unsealed Active value
(High, Medium and Low are cached), a null value, a blank value, the
names in any case, the browser tests' script and a null or blank script.
The cloud request engine's tests pass with no keys set (194 passed, 2
skipped live licence key tests, 4 live tests deselected), and taking out
either new check fails four of the new tests.
HumanConfidence is published with the values High, Medium, Low and
Unknown, so a sealed result is text that is not blank and is none of
those four, letter case ignored. is_sealed_value treated Unknown as
sealed and compared the other three in their exact case, so a response
whose HumanConfidence was Unknown, or a published value in another case,
was kept out of the response cache.

UNSEALED_VALUES now holds the four published values in lower case and
is_sealed_value compares the value in lower case. The cache tests cache
Unknown with an Active source, Unknown with no source or a Passive one,
and each published value in another letter case. The cloud request
engine's tests pass with no keys set (195 passed, 2 skipped live
licence key tests, 4 live tests deselected), and taking Unknown out of
UNSEALED_VALUES fails two of the cache tests.
HumanConfidence has the values High, Medium and Low only, so Unknown is
text other than those and counts as a sealed result, which the response
cache never stores or serves. This undoes the Unknown part of 8c5d400.
The letter case of a value is still ignored, as the rule says.

UNSEALED_VALUES is back to high, medium and low. The cache tests no
longer cache Unknown, and a new test checks that Unknown, with no source
or a Passive or Active one and in lower case, is neither stored nor
served. High, Medium and Low in another letter case are still cached.

The cloud request engine's tests pass with no keys set (196 passed, 2
skipped live licence key tests, 4 live tests deselected), and putting
Unknown back in UNSEALED_VALUES fails the new test.
Start Node once before the object name tests, outside their time limit
…ckages

Test the examples against the packages published on PyPI
HumanConfidence's values are High, Medium and Low. The cloud engine
listed Unknown as a fourth value, so a derived.humanconfidence of
Unknown was handed on as the property's value. It now reads as missing,
as any other text the property can't have does.

The tests read Unknown with the other text that is not a value, with and
without a sealed result, and no longer expect it to pass through.
…n-value

Read only High, Medium and Low as HumanConfidence values
…rowser-test-pass-through

Send every page iteration to the cloud, and keep responses made for one visitor out of the cache
BUILD: Take the free-threaded tests' data files from common-ci's shared copy
…oud Request Engine

A cloud engine accepts no evidence, so there is no key to use in a results
cache of its own, as the Cloud Aspect Engine specification says under
"Configuration options", where it recommends the cache goes on the Cloud
Request Engine instead.

- The cache setting of DeviceDetectionCloudPipelineBuilder,
  DeviceDetectionPipelineBuilder, IpIntelligenceCloudPipelineBuilder,
  IpIntelligencePipelineBuilder and LocationPipelineBuilder now adds the
  cache to the Cloud Request Engine, as .NET's cloud pipeline builders do.
  That engine keys the cache on the evidence it sends and applies its own
  cache rules, so a response made for one visitor is neither stored nor
  served, and a request that carries a session id, a sequence, JA4 or
  HTTP/2 settings, or a sealed result to redeem always goes to the cloud
  service. The on-premise branches are unchanged, because those engines
  already refuse a cache.
- CloudEngine.set_cache raises an exception that names the Cloud Request
  Engine, as the on-premise engines refuse a cache, and CloudEngine.process
  never uses a cache of the engine's own. DerivedCloud inherits both, so a
  redeemed Human Confidence result is never stored or served again.
- The builders' documentation says where the cache goes, and that with the
  JavaScript builder on every request carries a session id, which the Cloud
  Request Engine sends to the cloud service every time.

A caller that put a cache on a cloud engine directly now gets the
exception, and adds the cache to the Cloud Request Engine instead.

Tests, each failing on rc and passing here:
- test_builder_cache.py in fiftyone_devicedetection_cloud,
  fiftyone_ipintelligence_cloud and location, and in the two examples
  packages for the combined builders: the cache is on the Cloud Request
  Engine, two different requests give their own results, and the same
  evidence again is answered from the cache with the JavaScript builder off.
- test_cloudengine_cache.py: a cloud engine refuses a cache and reads each
  response whatever it holds.
- test_human_confidence.py: DerivedCloud refuses a cache, and one held
  anyway never serves a redeemed result.
Key the cloud engines' cache on the request's evidence and apply the Cloud Request Engine's cache rules
…e cache

The Cloud Request Engine sends a request carrying a session id, a sequence,
a JA4 or HTTP/2 settings to the cloud service whatever its cache holds, and
stores no answer to it. The existing tests supplied the JA4 and HTTP/2
settings together, or the session id and sequence together, so removing one
name from Constants.UNCACHED_EVIDENCE_NAMES left every test passing.

- test_cloudrequestengine_cache.py tests each of the four values alone,
  under two spellings each (another prefix and another letter case), with
  no other value made for one visitor. Each request reaches the cloud
  service carrying the value, is not answered from a cache that holds an
  entry for its evidence, and leaves nothing in the cache, so the same
  request again reaches the cloud service too.
- test_builder_cache.py in fiftyone_devicedetection_cloud builds the
  Device Detection Cloud Pipeline Builder with its defaults, the JavaScript
  builder included, and a cache. Three identical requests each reach the
  cloud service, because the sequence element gives every request a
  session id and a sequence, and the cache stays empty.

Each new test fails when its name is removed from the list. The builder
test fails when both the session id and the sequence are removed, as
either one alone still sends the request to the cloud service.
…alue

A page's scripts send their answers under a name that starts 51D_ and
changes with each script, so the cloud service lists none of them among its
evidence keys. The engine's cache key was made from the listed keys alone,
so a request carrying answers but no session id, sequence, JA4 or HTTP/2
settings (with add_sequence_element off, or from a caller's own route) was
answered from the cache with the response to other answers, and its own
answers never reached the cloud service.

The engine now accepts, beside the keys the service lists, every query or
cookie value whose name starts 51D_ in any letter case, the bare name 51D_
included, as the Rust Cloud Request Engine does. CloudEvidenceKeyFilter
adds the answers to the listed keys, and its list still holds the listed
keys alone, because the answers have no names to list, so the Vary header
the web integration writes is unchanged. What the engine sends is unchanged
too, as it already sent every evidence value. Being accepted evidence, the
answers are now part of the ETag of the web integration's client-side
responses, which changes with them.

Tests in test_cloudrequestengine_cache.py, each failing before this change:
- Two requests that differ only in a 51D_ value, under four spellings,
  each reach the cloud service and get their own answer, and the same value
  again is answered from the cache.
- The filter accepts the 51D_ query and cookie names and refuses a header,
  a server value, a name that only contains 51D_, a key with no prefix and
  a name whose first character is not ASCII.

test_discovery_at_build.py now watches CloudEvidenceKeyFilter, the class
the engine makes, to show a second request makes no filter.
The server route test checked the dictionary MockRequestClient records, and
its 51D_ values held no character a form body encodes, so it could not show
the values reach the cloud service unchanged.

- The posted answer and the cookie answer now carry +, %, =, a space and
  characters outside ASCII, through the Flask application and the web
  integration as before.
- WireClient answers as MockRequestClient does and also gives every request
  to RequestClient, the client the engine uses by default, with the network
  replaced, keeping the URL, the content type and the body it would send.
- The test checks each data request's body is a form body of ASCII text,
  that reading it as the cloud service does (UTF-8) gives back each answer,
  the cookie answer and the session id exactly, once each, and that each
  value is form encoded, with + as %2B, % as %25, = as %3D, a space as +
  and each byte of the UTF-8 of a character outside ASCII percent encoded.

The test fails if RequestClient joins the body without encoding it, and if
the engine decodes a value before sending it.
One LRUEngineCache is shared by every request an engine processes, and a
web server processes requests on several threads at once. The cachetools
LRUCache underneath changes its order on every read and removes the least
recently used entry on a write when full, with nothing holding threads
apart, so concurrent requests could raise KeyError or "OrderedDict mutated
during iteration" from inside the cache, or leave it inconsistent.

get_cache_value and set_cache_value now hold a threading.Lock while they
read or write the LRUCache, so one thread at a time is inside it.

test_lru_cache.py in fiftyone_pipeline_engines, both failing without the
lock on three runs out of three:
- Eight threads read and write one cache whose LRUCache pauses in each
  call and records how many threads are inside it at once, which is one.
- Eight threads make 3,000 reads and writes each on one cache of 8 entries
  over 32 keys, with the interpreter switching threads every microsecond.
  No thread raises, every read gives the value written for its key or
  nothing, the cache holds no more than 8 entries, and it still evicts the
  least recently used entry afterwards.
test_javascriptbuilder_object_name.py had LF line endings until the change
that kept two blank lines before _declared_names, which also turned every
line ending to CRLF, so that change showed as all 350 lines rewritten. The
file has LF line endings again, as every other Python file here does.

With white space ignored, the file differs from its version before the
Node start-up change only in setUpModule and the two constants,
NODE_CALL_SECONDS and NODE_START_SECONDS. Against the first commit of that
change, the only difference is the blank line the second one added.
…mples

After a run of Publish or Nightly Pipeline, the Examples vs Published
Packages workflow pinned each package to what PyPI's JSON gave as its
latest version at that moment, which straight after an upload can still be
the version before, so the examples could be tested against the previous
release with nothing to say so beyond the summary table.

ci/publish-package.ps1 pushes the tag '<package>/<version>' on the
published commit once each package is uploaded. The workflow now reads the
tags on that commit (git ls-remote, as the repository is public) and pins
each package the publish released to the version its tag names, waiting
until PyPI's simple index, which pip reads, lists that version. It asks
every $PyPIRetrySeconds (15) seconds and fails the run, naming the package
and version, after $PyPIWaitSeconds (900) seconds. A package with no tag on
that commit was not released by the publish, so it is pinned to its latest
version as before, and a version given by hand is used as before.

Run locally against PyPI with the step's script: a commit with no tags
pinned every package to its latest version, a version given by hand was
used for every package, and the 4.6.1 commit pinned the six pipeline
packages to 4.6.1 at once and failed, with a short wait, on
fiftyone-devicedetection-shared 4.6.1, which PyPI no longer lists.
… raise

CloudEngine.set_cache raised an exception, so code that gave a cloud engine
a cache, which worked before, would stop at start-up after a patch release.
A cloud engine accepts no evidence, so there is no key to use in a cache of
its own, and the cache belongs on the Cloud Request Engine, where the
pipeline builders now put it.

set_cache on a CloudEngine, and so on DerivedCloud and every engine built
on CloudEngine, now accepts the call and keeps no cache. It logs one
warning for each engine, however often the engine is given a cache, naming
the engine by its class and data key and saying to add the cache to the
Cloud Request Engine. The warning goes to the logger of each pipeline the
engine is in, or to the module's own logger
(fiftyone_pipeline_cloudrequestengine.cloudengine) while it is in none, and
nothing is logged as requests are processed. CloudEngine.process still
never uses a cache. This is how the Rust cloud engines treat a cache
setting, which is read and has no effect, with a warning logged.

Tests, the first three failing while set_cache raised:
- test_cloudengine_cache.py: a cache given before the engine is in a
  pipeline is accepted with one warning on the module's logger, and one
  given once the engine is in a pipeline with one warning on the
  pipeline's logger. In both, the engine keeps no cache, three requests
  each get their own value, the cache is never read or written and nothing
  more is logged. A cache assigned to the engine directly is never read or
  written either.
- test_human_confidence.py: DerivedCloud accepts a cache with one warning
  naming it, and a cache given through set_cache or assigned directly never
  serves a redeemed result and is never read or written.

Each warning test fails if the warning is logged on every call.
…lock

Cache key 51D_ values, per-visitor cache tests, thread-safe LRU cache and a warning for a cloud engine cache
…write

LRUEngineCache gained a lock in its constructor. A subclass whose own
constructor sets the cache without calling that constructor had no lock,
so its first read or write raised AttributeError. The lock is now made on
first use when the constructor did not make it, once per cache however many
threads ask at the same time.

Two tests cover a subclass that skips the constructor. Both fail without
the change.
…structor

Let a subclass of LRUEngineCache that skips its constructor read and write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants